package com.jstyle.jclifexd.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.jstyle.jclifexd.R;
import com.jstyle.jclifexd.adapter.FeedBackAdapter;
import com.jstyle.jclifexd.utils.ScreenUtils;
import com.jstyle.jclifexd.utils.Utils;

import java.util.Arrays;

import butterknife.BindArray;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class FeedbackListActivity extends AppCompatActivity {

    @BindView(R.id.bt_goal_back)
    Button btGoalBack;
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.iv_share)
    Button ivShare;
    @BindView(R.id.recyclerView_feedback)
    RecyclerView recyclerViewFeedback;
    @BindArray(R.array.feedback_array)
    String[]feedBackArray;
    private FeedBackAdapter feedBackAdapter;
    public static final String InFo="info";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_feedback_list);
        ButterKnife.bind(this);
        init();
    }

    private void init() {
        btGoalBack.setText(getString(R.string.FEED_BACK));
        ScreenUtils.setTitleTypeface(btGoalBack);

         feedBackAdapter=new FeedBackAdapter(Arrays.asList(feedBackArray));
        recyclerViewFeedback.setAdapter(feedBackAdapter);
        LinearLayoutManager linearLayoutManager=new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerViewFeedback.setLayoutManager(linearLayoutManager);
    }

    @OnClick({R.id.iv_back,R.id.iv_share})
    public void onViewClicked(View view) {
        if(Utils.isFastClick()){return;}
        switch (view.getId()){
            case R.id.iv_back:
                finish();
                break;
            case R.id.iv_share:
                String info=feedBackAdapter.getCheckedInfo();
                Intent intent=new Intent();
                intent.putExtra(InFo,info);
                setResult(RESULT_OK,intent);
                finish();
                break;
        }

    }
}
